package com.dy.security.config;

import com.dy.security.filter.MySecurityFilter;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;

/**
 * @ClassName:
 * @Author: dingyu
 * @Desctiption: (描述)
 * @Date: 2022/3/29 17:38
 * @Version 1.0 (版本)
 */
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {

    @Override
    protected void configure(HttpSecurity http) throws Exception {
        super.configure(http);
        //把自定义的过滤器添加到Spring Security过滤器链中
        http.addFilterBefore(new MySecurityFilter(), UsernamePasswordAuthenticationFilter.class);
    }
}
